﻿
using UnityEngine;

/// <summary>
/// Makes it possible to animate the widget's width and height using Unity's animations.
/// </summary>

[RequireComponent(typeof(RectTransform))]
[ExecuteInEditMode]
public class UGUIAnimatedSize : MonoBehaviour
{
	public float width = 1f;
	public float height = 1f;

    RectTransform mWidget;

	void OnEnable ()
	{
		mWidget = GetComponent<RectTransform>();
		LateUpdate();
	}

	void LateUpdate ()
	{
        mWidget.sizeDelta = new Vector2(Mathf.RoundToInt(width),
                                        Mathf.RoundToInt(height));
	}
}
